﻿/* Tips提示相关JS. add by terry */

/* 初始化工具提示. */
this.initToolTip=function(){
	return d3.select("body").append("div")
                .attr("class","tooltip")
                .attr("opacity",0.0)
                .on('dblclick',function(){
                    d3.event.stopPropagation();
                })
                .on('mouseover',function(){
                    if (_this.node.mouseoutTimeout) {
                        clearTimeout(_this.node.mouseoutTimeout);
                        _this.node.mouseoutTimeout = null;
                    }
                })
                .on('mouseout',function(){
                    if (_this.node.mouseoutTimeout) {
                        clearTimeout(_this.node.mouseoutTimeout);
                        _this.node.mouseoutTimeout = null;
                    }
                    _this.node.mouseoutTimeout=setTimeout(function() {
                        highlightToolTip(null);
                    }, 300);
                });
}

this.highlightToolTip=function(obj){

    if(obj){
	        var tooltipHtml = "<div class='title'>"+ obj["类型"] + "</div><table class='detail-info'>";
	        for(var key in obj){
			    tooltipHtml += "<tr><td class='td-label'>" + key + "：</td><td>" + obj[key] + "</td></tr>";
			}
			tooltipHtml += "</table>";
	
        _this.tooltip.html(tooltipHtml)
                .style("left",(d3.event.pageX+20)+"px")
                .style("top",(d3.event.pageY-20)+"px")
                .style("opacity",1.0);
    }else{
        _this.tooltip.style("opacity",0.0);
    }
};

